package com.example.example.controller;

import com.example.example.domain.ChatConverDTO;
import com.example.example.domain.ChatConverVO;
import com.example.example.result.Result;
import com.example.example.service.impl.ChatConverService;
import com.example.example.service.impl.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/chatConver")
public class ChatConverController {

    @Autowired
    private MessageService messageService;

    @Autowired
    private ChatConverService chatConverService;

    /**
     * 获取会话列表
     *
     * @return 会话列表
     */
    @GetMapping("/list")
    public Result<List<ChatConverVO>> getChatConverList() {
        List<ChatConverVO> chatConverDTOList = chatConverService.getChatConverList();
        return Result.ok(chatConverDTOList);
    }

    /**
     * 修改对话标题
     *
     * @return 会话列表
     */
    @PutMapping("/update")
    public Result<Void> updateChatConver(@RequestBody ChatConverDTO chatConverDTO) {
        messageService.updateChatConver(chatConverDTO);
        return Result.ok();
    }

}
